Skip to content

Examples: gas-phase chemistry validation (ignition, flame speed, reactive shock tube) - #2374

Merged
sbryngelson merged 12 commits into
MFlowCode:masterfrom
sbryngelson:f11-gas-chemistry
Nov 23, 2026
Merged

sbryngelson merged 12 commits into
MFlowCode:masterfrom
sbryngelson:f11-gas-chemistry

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Contribution Policy

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.

Summary

Adds checks of the gas-phase chemistry against Cantera: examples/1D_h2_air_ignition (constant-volume H2/air ignition, ignition delay, T(t) and UV equilibrium, split and in-stage reaction integrators), examples/1D_h2_air_flame_speed (1D premixed flame speed against a Cantera FreeFlame, GRCBC outflow) and a temperature comparison script plus reference table for examples/1D_reactive_shocktube (thesis Fig. 4.9 of Martinez Ferrer 2013). Each has a checker script and README; the results are on a new page docs/documentation/validation_gas_chemistry.md. One test is registered (1D -> Chemistry -> H2-Air Ignition -> Split Reactions, UUID 009447E8). 1D_h2_air_flame_speed is skipped from auto-registration (docs-only). 1D_reactive_shocktube/case.py gains --t_save_us and --substeps; defaults are unchanged. No src/ change.

Evidence

Measured on master (GNU 13, CPU, one rank, double): ignition tau error against Cantera +2.8e-6 / +1.1e-5 / +2.0e-5 at T0 = 1000 / 1100 / 1200 K (dt = 1e-8 s), max |dT| 0.29 K, T_end - T_eq +0.06 K; second order in dt (1.13 K at 2e-8, 6.46 K at 5e-8); in-stage integrator at 5e-10 s agrees to 2e-11. Flame speed S_c error -0.76 % (40 um) and -0.21 % (20 um). Shock tube at 401 / 801 cells: leading shock 43.16 / 43.25 mm at 170 us (reference 43.25), L1 temperature difference 1.0 / 2.5 / 4.2 % at 170 / 190 / 230 us, burnt gas about 100 K hotter (different mechanism from the reference, verified in 0D on a pre-merge build only). These match the earlier pre-merge measurements. Golden: GNU 13 CPU; NVIDIA A100 with NVHPC 25.11 agrees to 2e-12 relative; NVHPC 25.5 differs by up to 1e-3 in minor species (see issue #2181); the new test is skipped on NVHPC < 25.11 GPU builds (UUID 009447E8 added to NVHPC_GPU_KNOWN_DIFFERENCE_UUIDS); CPU builds run it. The 25.5 difference needs -O1 or higher on the GPU path, is not understood, and is isolated in the #2181 comment; the tolerance is not loosened to hide it. The hand-test comment follows.

Scope

Not included: the second (11-species CO) mechanism, the thesis velocity, gamma and Y_H comparisons, a registered flame or shock-tube test (too long), figures. The 10 and 5 um flame rows are quoted from an earlier build and labeled so. Open: single-precision and CI-lane behavior of the new test (golden tolerance set from the CI spread after the first run).

Test plan

./mfc.sh test --only 009447E8; checkers as in the page's Reproduce section.

Related issues: #2399, #2403

This PR was made with Claude Code (AI).

@sbryngelson

Copy link
Copy Markdown
Member Author

Hand test of 1D -> Chemistry -> H2-Air Ignition -> Split Reactions (009447E8), commit ecbe4b0 (examples and test identical in the current head), no MPI, one rank:

  • GNU 13.3, CPU: golden generated here; test passes.
  • NVIDIA A100 80GB, NVHPC 25.11 (--gpu acc): ./mfc.sh test --no-build --no-mpi --gpu acc --only 009447E8 passes; regenerated values agree with the golden to 1.8e-12 relative (worst value above 1e-9).
  • NVIDIA A100 80GB, NVHPC 25.5 (--gpu acc): FAILS the tolerance. Species differ from the GNU/25.11 values by up to 4.8e-4 relative (e.g. cons.6 at 80 us, species of mass fraction 1e-4), 1e-7 already at 20 us before ignition; density and total energy agree. The case is a uniform box, so this is not chaotic ignition. Same symptom class as 124D7972 on 25.5 (issue Phoenix CI failing on master #2181). The Phoenix NVHPC 25.5 lane may therefore fail; I have not changed the tolerance and will set it from the CI lane spread.

Checkers (GNU 13, CPU): see the numbers in the PR body and the validation page.

@sbryngelson

Copy link
Copy Markdown
Member Author

Correction to the hand-test comment above: the "1e-7 already at 20 us, before ignition" figure came from the text output, which prints 14 decimals (an absolute resolution of 1e-14, i.e. 1e-7 relative for a species of 1e-7). It is not a real difference. Isolation on the A100 (same case, 100 saves; max over species of the difference from the GNU 13 CPU run, relative to each species' maximum):

Build step 1000 (20 us) 2000 (40 us) 3000 (60 us) 5000 (100 us)
NVHPC 25.11 GPU 0 0 0 0
NVHPC 25.11 GPU, CUDA 12.9 0 0 0 0
NVHPC 25.11 GPU, no -Mfprelaxed 0 0 0 0
NVHPC 25.5 CPU 0 0 0 0
NVHPC 25.5 GPU 1e-7 (print resolution) 4e-4 4e-4 2.5e-4
NVHPC 25.5 GPU, no -Mfprelaxed same as above same same same
NVHPC 25.5 GPU, -gpu=nofma and -Mnofma same same same same
NVHPC 25.5 GPU, -O1 same same same same

The 25.5 GPU difference first appears in the radical species at about 14 to 30 us (the induction period) and grows to 1e-3 around ignition; it is independent of -Mfprelaxed, FMA contraction, -O level and the CUDA toolkit (12.9 vs 13.0 with 25.11), and absent on the 25.5 CPU build. So it comes from the 25.5 GPU code generation or runtime, not from those flags. The first species source vector was not compared (the output resolution hides a ulp-level difference). The test is expected to differ on NVHPC 25.5 (#2181); I am not loosening the tolerance to hide it.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: cba6bb9

Files changed:

  • 16
  • docs/documentation/validation.md
  • docs/documentation/validation_gas_chemistry.md
  • docs/references.bib
  • examples/1D_h2_air_flame_speed/case.py
  • examples/1D_h2_air_flame_speed/compare_flame_speed.py
  • examples/1D_h2_air_ignition/case.py
  • examples/1D_h2_air_ignition/compare_cantera.py
  • examples/1D_reactive_shocktube/case.py
  • toolchain/mfc/test/cases.py
  • toolchain/mfc/test/test.py

Findings:

  • high docs/references.bib: The new @phdthesis{MartinezFerrer2013, ...} entry has no closing }. The hunk ends at note = {HAL tel-00937313} and the next line is @article{DennisChang1970,; the post-change file at line 873 confirms this. BibTeX/Doxygen will fail to parse this entry and will probably swallow DennisChang1970. The new page cites \cite MartinezFerrer2013, so the citation breaks too. Fix: add } on its own line after the note line. Confidence: high.

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.14%. Comparing base (4264341) to head (7f4db78).
⚠️ Report is 32 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2374      +/-   ##
==========================================
+ Coverage   65.72%   66.14%   +0.41%     
==========================================
  Files         111      112       +1     
  Lines       30549    31093     +544     
  Branches     4673     4749      +76     
==========================================
+ Hits        20079    20567     +488     
+ Misses       6699     6675      -24     
- Partials     3771     3851      +80     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson
sbryngelson merged commit 6947e52 into MFlowCode:master Nov 23, 2026
50 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant